<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./Test.xhtml">



            <ui:define name="content">
                <f:view>
                    <fieldset style="height: 700px">
                        <legend><b>Add new event</b></legend>
                        <h:form style="background-color: white;" enctype="multipart/form-data">

                            <center> <table width="716" height="513">
                                    <tr>
                                        <td><h2>Add New Events!</h2></td>
                                    </tr>

                                    <tr>
                                        <td><b>Category *</b></td>
                                        <td>
                                            <h:selectOneMenu id="selectCat" value="#{eventBean.catId}" >
                                                <f:selectItems value="#{categoryBean.listAllCategory}" var="item" itemLabel="#{item.categoryName}" itemValue="#{item.categoryId}"/>
                                            </h:selectOneMenu>
                                        </td>
                                        <td>

                                        </td>
                                    </tr>

                                    <tr>
                                        <td height="47"><b>Event Title *</b></td>
                                        <td><p:inputText value="#{eventBean.event.eventTitle}" id="txttitle" required="true" requiredMessage="Event title is not null">
                                                <f:ajax event="change" execute="txttitle" listener="#{eventBean.checkEventTitle}"/>
                                                <f:validator validatorId="Validator.StringValidator"/>
                                            </p:inputText></td>
                                        <td>
                                            <h:outputText id="display" value="#{eventBean.msTitle}" style="font-size: smaller;font-weight: normal;color: red"/>
                                            <p:message for="txttitle"/></td>
                                    </tr>

                                    <tr>
                                        <td height="45"><b>Event Info *</b></td>
                                        <td><p:editor value="#{eventBean.event.eventInfo}" id="txtInfo" required="true" requiredMessage="Event info is not null"/></td>
                                        <td><p:message for="txtInfo"/></td>
                                    </tr>

                                    <tr>
                                        <td height="48"><b>Event Images *</b></td>
                                        <td>

                                            <p:growl id="messages" showSummary="true" showDetail="true" />
                                            <p:fileUpload fileUploadListener="#{eventBean.handleFileUpload}"
                                                          update="messages,uploadedFile"  sizeLimit="1073741824"
                                                          multiple="true" label="choose" allowTypes="*.jpg;*.png;*.gif;"
                                                          description="Images"/>
                                        

                                        </td>

                                        <td></td>
                                    </tr> 

                                    <tr>
                                        <td height="45"><b>Release Date *</b></td>
                                        <td><p:calendar value="#{eventBean.event.releaseDate}" id="txtreleaseDate" required="true" requiredMessage="ReleaseDate is not null"/>  </td>
                                        <td>
                                            <p:message for="txtreleaseDate"/></td>
                                    </tr>

                                    <tr>
                                        <td height="45"><b>End Date </b></td>
                                        <td><p:calendar value="#{eventBean.event.endDate}" id="txtendDate" required="true" requiredMessage="endDate is not null"/>  </td>
                                        <td>
                                            <p:message for="txtendDate"/></td>
                                    </tr>
                                    <tr>
                                        <td height="61"><b>Duration *</b></td>
                                        <td><p:inputText value="#{eventBean.event.duration}" id="txtduration" required="true" requiredMessage="Duration is not null">
                                                <f:validator validatorId="Validator.CheckNumber"/>
                                            </p:inputText>

                                        </td>
                                        <td><p:message for="txtduration"/></td>
                                    </tr>
                                    <tr>
                                        <td height="65"></td>
                                        <td>
                                            <h:commandButton value="Add New" action="Event" actionListener="#{eventBean.insertEvent}" type="image" image="../resources/images/forms/form_submit.gif"/>
                                            <h:commandButton value="Cancel" action="Event" type="image" image="../resources/images/forms/form_reset.gif"/>
                                        </td>
                                        <td></td>
                                    </tr>
                                </table>
                            </center>
                        </h:form>
                    </fieldset>
                </f:view>
            </ui:define>



        </ui:composition>

    </body>
</html>
